package routers

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

// ApiRouters
//
//	@Description:
//	@param engine 将gin引擎传入
func ApiRouters(engine *gin.Engine) {
	//路由分组嵌套
	apiRouters := engine.Group("/api")
	{

		// http://localhost:8888//api
		apiRouters.GET("/", func(c *gin.Context) {
			c.String(http.StatusOK, "%s", "api首页！")
		})

		//路由分组嵌套-下路由分组
		userRouters := apiRouters.Group("/user")
		{
			//http://localhost:8888/api/user/get
			userRouters.GET("/get", func(c *gin.Context) {
				c.String(http.StatusOK, "%s", "获取用户信息！")
			})
			//http://localhost:8888/api/user/del
			userRouters.GET("/del", func(c *gin.Context) {
				c.String(http.StatusOK, "%s", "删除用户！")
			})
		}

		//路由分组嵌套-下路由分组
		goodsRouters := apiRouters.Group("/goods")

		{
			//http://localhost:8888/api/goods/
			goodsRouters.GET("/", func(c *gin.Context) {
				c.String(http.StatusOK, "%s", "商品首页！")
			})
			//http://localhost:8888/api/goods/del
			goodsRouters.GET("/get", func(c *gin.Context) {
				c.String(http.StatusOK, "%s", "获取商品信息！")
			})

			//http://localhost:8888/api/goods/del
			goodsRouters.GET("/del", func(c *gin.Context) {
				c.String(http.StatusOK, "%s", "删除商品信息！")
			})
		}

	}
}
